import requests


class Test:
    def abc(self):
        return 10 + 20


t = Test()
ret = t.abc()

print(ret)

# 1. 创建Session 实例
my_session = requests.Session()

# 2. 用实例，发送 获取验证码请求
resp_verify = my_session.get(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify&r=0.7794573621727154")

# 3. 用实例，发送 登录请求
resp_login = my_session.post(
    url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.4003948083916662",
    headers={"Content-Type": "application/x-www-form-urlencoded"},
    data={"username": "13812345678", "password": "123456", "verify_code": "8888"})
# 打印响应结果
print("打印json格式的结果：", resp_login.json())

# 4. 关闭 session
my_session.close()
